//
//  HSObjectiveTableViewCell.swift
//  HomeSchoolDemo
//
//  Created by rimi on 2016/10/13.
//  Copyright © 2016年 黄华强. All rights reserved.
//

import UIKit

class HSObjectiveTableViewCell: UITableViewCell {

    var ht_titleLabel:UILabel!
    var ht_typeView:HSMyView!
    var ht_contentView:HSObjectiveView!
    
    var model:HSHW_htViewModel? {
        didSet {
           setupUI()
        }
    }
    
    func setupUI() {
        
        ht_titleLabel = UILabel(title: model?.details.ht_title ?? "", color: UIColor().colorWithHex(0x005780), fontSize: 15)
        ht_titleLabel.numberOfLines = 0
        contentView.addSubview(ht_titleLabel)
        
        ht_titleLabel.snp.makeConstraints { (make) in
            make.left.equalTo(8)
            make.right.equalTo(-screenW * 0.15)
            make.top.equalTo(8)
            
        }

        
        var viewStr: String = ""
        var viewColor: UIColor = #colorLiteral(red: 0.9372549057, green: 0.3490196168, blue: 0.1921568662, alpha: 1)
        let a = model?.details.ht_type ?? 0
        switch a {
        case 1:
            viewStr = "单选"
            viewColor = #colorLiteral(red: 0.9372549057, green: 0.3490196168, blue: 0.1921568662, alpha: 1)
        case 2:
            viewStr = "多选"
            viewColor = #colorLiteral(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1)
        case 3:
            viewStr = "对错"
            viewColor = #colorLiteral(red: 0.9607843161, green: 0.7058823705, blue: 0.200000003, alpha: 1)
        case 4:
            viewStr = "主观"
            viewColor = #colorLiteral(red: 0.3098039329, green: 0.01568627544, blue: 0.1294117719, alpha: 1)
        default:
            break
        }
        let testView = HSMyView(frame:CGRect(x: screenW * 0.88, y: 0, width: 28, height: 30) , title: viewStr, color: viewColor)
        testView.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        contentView.addSubview(testView)

        ht_contentView = HSObjectiveView(frame: CGRect(x: 8, y: (model?.titleH)! + 16, width: screenW * 0.85, height: (model?.contentViewH)!))
        ht_contentView.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        
        ht_contentView.model = model
        
        contentView.addSubview(ht_contentView)

        
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        
    }

}
